Conversation
Owner
Author
|
Понял свою ошибку, я сортировал не имена файлов а список состоящий из пар (byte[], имя файла) |
Comment on lines
+5
to
+8
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| } |
There was a problem hiding this comment.
Suggested change
| [SetUp] | |
| public void Setup() | |
| { | |
| } |
| /// <summary> | ||
| /// Class representing the calculation of the check sum | ||
| /// </summary> | ||
| public class MD5 |
There was a problem hiding this comment.
Все методы static, следовательно и сам класс мог бы быть static
| /// </summary> | ||
| public class MD5 | ||
| { | ||
| public static async Task<byte[]> ComputeCheckSumForFile(string path) |
There was a problem hiding this comment.
А тут комментария не хватает. И я бы его и методы ниже сделал private — не пользователь должен решать, файл у нас или папка. Я как пользователь хочу просто передать путь и получить хеш, думать не хочу.
| /// Function for sequential calculation of the check sum of the directory | ||
| /// </summary> | ||
| /// <param name="pathToDirectory">Path to directory</param> | ||
| /// <returns></returns> |
| var directories = Directory.GetDirectories(pathToDirectory); | ||
| var list = new List<(byte[], string)>(); | ||
|
|
||
| foreach(var directory in directories) |
There was a problem hiding this comment.
Suggested change
| foreach(var directory in directories) | |
| foreach (var directory in directories) |
Comment on lines
+92
to
+93
| Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory))); | ||
| Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file))); |
Comment on lines
+99
to
+102
| var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!); | ||
|
|
||
|
|
||
| foreach (var (lol, bytes) in list) |
There was a problem hiding this comment.
Suggested change
| var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!); | |
| foreach (var (lol, bytes) in list) | |
| var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!); | |
| foreach (var (lol, bytes) in list) |
Comment on lines
+7
to
+10
| } | ||
|
|
||
|
|
||
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) |
There was a problem hiding this comment.
Suggested change
| } | |
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) | |
| } | |
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) |
Comment on lines
+41
to
+42
| //stream.WriteLine(); | ||
| //stream.Write($"{size} {Math.Round(averageForStandardCalculations, 3)} {Math.Round(Math.Sqrt(varianceForStandardCalculations), 3)} {Math.Round(averageForParallelCalculations, 3)} {Math.Round(Math.Sqrt(varianceForParallelCalculations), 3)}"); |
| // После просто Task.Run(() => {...}) и объединять Task.Result | ||
| // Но так вроде выглядит проще | ||
| Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory))); | ||
| Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file))); |
There was a problem hiding this comment.
И ComputeCheckSumForFile тут. Как тестировали, оно же падает сразу? :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.